import tools from "@/common/tools.js";
import {
	post
} from '@/common/axios.js';
import {
	addFeedback, //意见反馈
	getbannerList ,//轮播图
	getAgreement//获取协议
} from '@/common/path.js'

export default {
	//用户照片操纵
	namespaced: true,
	state: {
		userInfo: uni.getStorageSync('userInfo'),
		photoList: [], //相册列表
		bannerList:[],//轮播图
		agreementData:{},//协议
	},
	getters: {

	},
	mutations: {
		SET_LIST(state, data) { //相册
			state.photoList = data
		},
		SET_BANNER_LIST(state, data) { //轮播图
			state.bannerList = data
		},
		SET_AGREEMENT(state, data) { //协议
			state.agreementData = data
		},


	},
	actions: {
		//协议
		getAgreement({
			dispatch,
			commit,
			state
		}, args = {}) {
			post(getAgreement, args).then(res => {
				if (res.code == 0) {
					commit('SET_AGREEMENT',res.data);
				} 
			})
		},
		
		//相册
		addFeedback({
			dispatch,
			commit,
			state
		}, args = {}) {
			post(addFeedback, args).then(res => {
				if (res.code == 0) {
					tools.showToast2(res.msg)
					setTimeout(r => {
						tools.back()
					}, 1000)
				} 
			})
		},
		//轮播图
		getbannerList({
			dispatch,
			commit,
			state
		}, args = {}) {
			post(getbannerList, args).then(res => {
				if (res.code == 0) {
					commit('SET_BANNER_LIST', res.data)
				} else {
					tools.showToast(res.msg)
				}
			})
		}


	},
}
